<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        #box {
            width: 100px;
            height: 100px;
            border: 1px solid #000;
            padding: 100px;
            -webkit-perspective: 300px;
            perspective: 300px;
            /* perspective-origin: center center; */
        }

        .div {
            position: relative;
            width: 100px;
            height: 100px;
            /* background: red; */
            transition: 3s;
            /* transform: center center; */
            /* transform-origin: left center; */
            -webkit-transform-style: preserve-3d;
            transform-style: preserve-3d
        }

        .div span {
            position: absolute;
            left: 0;
            top: 0;
            width: 100px;
            height: 100px;
            display: block;
            font-size: 50px;
            text-align: center;
            line-height: 100px;
            /* -webkit-transform: rotateX(60deg); */
            /* transform: rotateX(60deg) */
            color: white;
            -webkit-backface-visibility: hidden;
            backface-visibility: hidden;
            opacity: .5;
            transform-style: preserve-3d;
        }

        .div span:nth-of-type(1) {
            background: red;
            left: 25px;
            top: 25px;
            width: 50px;
            height: 50px;
            font-size: 25px;
            line-height: 50px;
            -webkit-transform-style: translateZ(10px) rotateY(0deg);
            transform: translateZ(10px) rotateY(0deg);
        }

        .div span:nth-of-type(2) {
            background: green;
            -webkit-transform-style: rotateY(180deg);
            transform: rotateY(180deg);
        }
    </style>
    <script>
        /**
            rotateX/rotateY/rotateZ/rotate3D
            translateX/translateY/translateZ/translate3d
            perspective 景深(我在多远 之外来看这个元素)
            加给要做3d变换的元素的父级
            transform-style 元素在做3d变换时，是否保留子元素的3d变换
            flat 不保留
            preserve-3d
            隐藏背面
            反面：与父级视角相对的
        */
        document.addEventListener("ontouchstart", function (ev) {
            ev.preventDefault();
        })
        window.onload = function () {
            var div = document.querySelectorAll('.div');

            div[0].style.WebkitTransform = div[0].transform = "rotateY(360deg)";

        }
    </script>
</head>

<body>
    <div id="box">
        <div class="div">
            <span>正</span>
            <span>反</span>
        </div>
    </div>
</body>

</html>